<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="utf-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, height=device-height, initial-scale=1, user-scalable=no">
  <meta name="description" content="API docs for the executeAction method from the InstantExportAction class, for the Dart programming language.">
  <title>executeAction method - InstantExportAction class - creator library - Dart API</title>


  
  <link rel="preconnect" href="https://fonts.gstatic.com">
  <link href="https://fonts.googleapis.com/css2?family=Roboto+Mono:ital,wght@0,300;0,400;0,500;0,700;1,400&display=swap" rel="stylesheet">
  <link href="https://fonts.googleapis.com/css2?family=Material+Symbols+Outlined:opsz,wght,FILL,GRAD@48,400,0,0" rel="stylesheet">
  
  <link rel="stylesheet" href="../../static-assets/github.css?v1">
  <link rel="stylesheet" href="../../static-assets/styles.css?v1">
  <link rel="icon" href="../../static-assets/favicon.png?v1">

  
</head>


<body data-base-href="../../" data-using-base-href="false" class="light-theme">

<div id="overlay-under-drawer"></div>

<header id="title">
  <span id="sidenav-left-toggle" class="material-symbols-outlined" role="button" tabindex="0">menu</span>
  <ol class="breadcrumbs gt-separated dark hidden-xs">
    <li><a href="../../index.html">yuuna</a></li>
    <li><a href="../../creator/creator-library.html">creator</a></li>
    <li><a href="../../creator/InstantExportAction-class.html">InstantExportAction</a></li>
    <li class="self-crumb">executeAction method</li>
  </ol>
  <div class="self-name">executeAction</div>
  <form class="search navbar-right" role="search">
    <input type="text" id="search-box" autocomplete="off" disabled class="form-control typeahead" placeholder="Loading search...">
  </form>
  <div class="toggle" id="theme-button">
    <label for="theme">
      <input type="checkbox" id="theme" value="light-theme">
      <span id="dark-theme-button" class="material-symbols-outlined">
        brightness_4
      </span>
      <span id="light-theme-button" class="material-symbols-outlined">
        brightness_5
      </span>
    </label>
  </div>
</header>
<main>

  <div id="dartdoc-main-content" class="main-content">
      <div>
<h1><span class="kind-method">executeAction</span> method 
</h1></div>

    <section class="multi-line-signature">
      
  <div>
    <ol class="annotation-list">
        <li>@<a href="https://api.flutter.dev/flutter/dart-core/override-constant.html">override</a></li>
    </ol>
  </div>

<span class="returntype"><a href="https://api.flutter.dev/flutter/dart-async/Future-class.html">Future</a><span class="signature">&lt;<wbr><span class="type-parameter">void</span>&gt;</span></span>
<span class="name ">executeAction</span>(<wbr><ol class="parameter-list"><li><span class="parameter" id="executeAction-param-context">{<span>required</span> <span class="type-annotation"><a href="https://api.flutter.dev/flutter/widgets/BuildContext-class.html">BuildContext</a></span> <span class="parameter-name">context</span>, </span></li>
<li><span class="parameter" id="executeAction-param-ref"><span>required</span> <span class="type-annotation"><a href="https://pub.dev/documentation/flutter_riverpod/1.0.4/flutter_riverpod/WidgetRef-class.html">WidgetRef</a></span> <span class="parameter-name">ref</span>, </span></li>
<li><span class="parameter" id="executeAction-param-appModel"><span>required</span> <span class="type-annotation"><a href="../../models/AppModel-class.html">AppModel</a></span> <span class="parameter-name">appModel</span>, </span></li>
<li><span class="parameter" id="executeAction-param-creatorModel"><span>required</span> <span class="type-annotation"><a href="../../models/CreatorModel-class.html">CreatorModel</a></span> <span class="parameter-name">creatorModel</span>, </span></li>
<li><span class="parameter" id="executeAction-param-heading"><span>required</span> <span class="type-annotation"><a href="../../dictionary/DictionaryHeading-class.html">DictionaryHeading</a></span> <span class="parameter-name">heading</span>, </span></li>
<li><span class="parameter" id="executeAction-param-dictionaryName"><span>required</span> <span class="type-annotation"><a href="https://api.flutter.dev/flutter/dart-core/String-class.html">String</a>?</span> <span class="parameter-name">dictionaryName</span>}</span></li>
</ol>)

      <div class="features"><span class="feature">override</span></div>

    </section>
    
<section class="desc markdown">
  <p>Execute the functionality of this action.</p>
</section>


    
<section class="summary source-code" id="source">
  <h2><span>Implementation</span></h2>
  <pre class="language-dart"><code class="language-dart">@override
Future&lt;void&gt; executeAction({
  required BuildContext context,
  required WidgetRef ref,
  required AppModel appModel,
  required CreatorModel creatorModel,
  required DictionaryHeading heading,
  required String? dictionaryName,
}) async {
  CreatorModel creatorModel = ref.read(instantExportProvider);

  Map&lt;Field, String&gt; newTextFields = {};
  for (Field field in appModel.activeFields) {
    String? newTextField = field.onCreatorOpenAction(
      context: context,
      ref: ref,
      appModel: appModel,
      creatorModel: creatorModel,
      heading: heading,
      creatorJustLaunched: true,
      dictionaryName: dictionaryName,
    );

    if (newTextField != null) {
      newTextFields[field] = newTextField;
    }
  }

  creatorModel.copyContext(
    CreatorFieldValues(textValues: newTextFields),
  );

  for (Field field in appModel.activeFields) {
    &#47;&#47;&#47; If a media source has a generate images or audio function, then use that
    &#47;&#47;&#47; over any set auto enhancement.
    if (appModel.isMediaOpen &amp;&amp; appModel.getCurrentMediaItem() != null) {
      MediaSource mediaSource =
          appModel.getCurrentMediaItem()!.getMediaSource(appModel: appModel);
      if (field is ImageField &amp;&amp; mediaSource.overridesAutoImage) {
        await field.setImages(
          appModel: appModel,
          creatorModel: creatorModel,
          searchTerm: &#39;&#39;,
          newAutoCannotOverride: true,
          cause: EnhancementTriggerCause.manual,
          generateImages: () async {
            return mediaSource.generateImages(
              appModel: appModel,
              item: appModel.getCurrentMediaItem()!,
              options: appModel.currentSubtitleOptions!.value,
              data: mediaSource.currentExtraData,
            );
          },
        );
        continue;
      }
      if (field is AudioSentenceField &amp;&amp; mediaSource.overridesAutoAudio) {
        await field.setAudio(
          appModel: appModel,
          creatorModel: creatorModel,
          searchTerm: &#39;&#39;,
          newAutoCannotOverride: true,
          cause: EnhancementTriggerCause.manual,
          generateAudio: () async {
            return mediaSource.generateAudio(
              appModel: appModel,
              item: appModel.getCurrentMediaItem()!,
              options: appModel.currentSubtitleOptions!.value,
            );
          },
        );
        continue;
      }
    }

    Enhancement? enhancement = appModel.lastSelectedMapping
        .getAutoFieldEnhancement(appModel: appModel, field: field);

    if (enhancement != null) {
      await enhancement.enhanceCreatorParams(
        context: context,
        ref: ref,
        appModel: appModel,
        creatorModel: creatorModel,
        cause: EnhancementTriggerCause.auto,
      );
    }
  }

  await appModel.addNote(
    creatorFieldValues: creatorModel.getExportDetails(ref),
    mapping: appModel.lastSelectedMapping,
    deck: appModel.lastSelectedDeckName,
    onSuccess: () {
      creatorModel.clearAll(
        overrideLocks: true,
        savedTags: appModel.savedTags,
      );

      &#47;&#47;&#47; Need to clear media as these conflict.
      CreatorModel cardCreatorModel = ref.read(creatorProvider);
      cardCreatorModel.clearField(
        ImageField.instance,
        savedTags: appModel.savedTags,
      );
      cardCreatorModel.clearField(
        AudioField.instance,
        savedTags: appModel.savedTags,
      );
      cardCreatorModel.clearField(
        SentenceField.instance,
        savedTags: appModel.savedTags,
      );
    },
  );
}</code></pre>
</section>


  </div> <!-- /.main-content -->

  <div id="dartdoc-sidebar-left" class="sidebar sidebar-offcanvas-left">
    <header id="header-search-sidebar" class="hidden-l">
  <form class="search-sidebar" role="search">
    <input type="text" id="search-sidebar" autocomplete="off" disabled class="form-control typeahead" placeholder="Loading search...">
  </form>
</header>

<ol class="breadcrumbs gt-separated dark hidden-l" id="sidebar-nav">
  <li><a href="../../index.html">yuuna</a></li>
  <li><a href="../../creator/creator-library.html">creator</a></li>
  <li><a href="../../creator/InstantExportAction-class.html">InstantExportAction</a></li>
  <li class="self-crumb">executeAction method</li>
</ol>


    <h5>InstantExportAction class</h5>
    <ol>

        <li class="section-title"><a href="../../creator/InstantExportAction-class.html#constructors">Constructors</a></li>
          <li><a href="../../creator/InstantExportAction/InstantExportAction.html">InstantExportAction</a></li>


        <li class="section-title inherited">
          <a href="../../creator/InstantExportAction-class.html#instance-properties">Properties</a>
        </li>
          <li class="inherited"><a href="../../creator/QuickAction/description.html">description</a></li>
          <li class="inherited"><a href="../../creator/QuickAction/descriptionLocalisation.html">descriptionLocalisation</a></li>
          <li class="inherited"><a href="https://api.flutter.dev/flutter/dart-core/Object/hashCode.html">hashCode</a></li>
          <li class="inherited"><a href="../../creator/QuickAction/icon.html">icon</a></li>
          <li class="inherited"><a href="../../creator/QuickAction/label.html">label</a></li>
          <li class="inherited"><a href="../../creator/QuickAction/labelLocalisation.html">labelLocalisation</a></li>
          <li class="inherited"><a href="https://api.flutter.dev/flutter/dart-core/Object/runtimeType.html">runtimeType</a></li>
          <li class="inherited"><a href="../../creator/QuickAction/showInSingleDictionary.html">showInSingleDictionary</a></li>
          <li class="inherited"><a href="../../creator/QuickAction/uniqueKey.html">uniqueKey</a></li>

        <li class="section-title"><a href="../../creator/InstantExportAction-class.html#instance-methods">Methods</a></li>
          <li><a href="../../creator/InstantExportAction/executeAction.html">executeAction</a></li>
          <li><a href="../../creator/InstantExportAction/getIconColor.html">getIconColor</a></li>
          <li class="inherited"><a href="../../creator/QuickAction/getLocalisedDescription.html">getLocalisedDescription</a></li>
          <li class="inherited"><a href="../../creator/QuickAction/getLocalisedLabel.html">getLocalisedLabel</a></li>
          <li class="inherited"><a href="../../creator/QuickAction/initialise.html">initialise</a></li>
          <li class="inherited"><a href="https://api.flutter.dev/flutter/dart-core/Object/noSuchMethod.html">noSuchMethod</a></li>
          <li class="inherited"><a href="../../creator/QuickAction/prepareResources.html">prepareResources</a></li>
          <li class="inherited"><a href="https://api.flutter.dev/flutter/dart-core/Object/toString.html">toString</a></li>

        <li class="section-title inherited"><a href="../../creator/InstantExportAction-class.html#operators">Operators</a></li>
          <li class="inherited"><a href="https://api.flutter.dev/flutter/dart-core/Object/operator_equals.html">operator ==</a></li>




        <li class="section-title"><a href="../../creator/InstantExportAction-class.html#constants">Constants</a></li>
          <li><a href="../../creator/InstantExportAction/key-constant.html">key</a></li>
</ol>

  </div><!--/.sidebar-offcanvas-->

  <div id="dartdoc-sidebar-right" class="sidebar sidebar-offcanvas-right">
  </div><!--/.sidebar-offcanvas-->

</main>

<footer>
  <span class="no-break">
    yuuna
      2.8.0+93
  </span>

  
</footer>



<script src="../../static-assets/highlight.pack.js?v1"></script>
<script src="../../static-assets/docs.dart.js"></script>



</body>

</html>

